{include file="public/header"/}





<div class="wrapper">
	<div class="mod-toolbar-top cf">
		<div class="fl">
			<strong class="tit">仓库</strong>
			<!-- <div class="tab-item-other" id="openUrl"><a href="https://club.kingdee.com/club/newclub/school/course?product_id=7&amp;cid=1547#pid=5683" target="_blank" class="video-icon"></a>仓库管理</div> -->
		</div>
		<div class="fr">
			<a href="#" class="ui-btn ui-btn-sp mrb ui-btn-add" id="btn-add" onclick="lopen('add.html','新增', '400px', '300px')">新增</a>
			<!--<a class="ui-btn mrb" id="btn-disable">禁用</a><a class="ui-btn mrb" id="btn-enable">启用</a>-->
			<!--<a class="ui-btn mrb" id="btn-print">打印</a>-->
			<a class="ui-btn mrb" id="btn-import">导入</a>
			<!--<a class="ui-btn mrb" id="btn-export">导出</a>-->
			<a class="ui-btn" id="btn-refresh" onclick="reload()">刷新</a>
		</div>
	</div>
	<div class="grid-wrap">
		<table id="grid">
		</table>
		<div id="page"></div>
	</div>


	<script type="text/javascript">
		//刷新
		function reload(){
			$("#grid").jqGrid('setGridParam').trigger("reloadGrid"); //重新载入
			return false;
		}
		$(document).ready(function () {
			//alert("1111");
			$("#grid").jqGrid({
				url: '/admin/store/index.html?ajax=100',
				datatype: "json",//数据来源，本地数据（local，json,jsonp,xml等）
				height: '90%',//高度，表格高度。可为数值、百分比或'auto'
				//width: Public.setGrid().w,
				//height: Public.setGrid().h,
				colNames: ["操作", "仓库编号", "仓库名称", "状态"],
				colModel: [
					{ name: 'id', index: 'id', width: 70, formatter: actions },
					{ name: 'bh', width: 150 },
					{ name: 'name', index: 'name asc', width: 350 },
					{ name: 'status', index: 'name asc', width: 100, align:'center', formatter: cLink },
				],
				rowNum: 10,
				rowList: [10, 20, 30],
				sortname: 'id',
				sortorder: "desc",
				pagerpos: "left",//分页位置

				pgbuttons: true,//翻页按钮
				pagination: true,
				altRows: !0,
				gridview: !0,
				shrinkToFit: !1,
				cellLayout: 8,
				autowidth: !0,
				pager: "#page",
				viewrecords: !0,
				cmTemplate: {
					sortable: !1,
					title: !1
				},
				loadError: function (t, e, i) {
					parent.Public.tips({
						type: 1,
						content: "操作失败了哦，请检查您的网络链接！"
					})
				}
			});
		});

		function cLink(cellvalue, options, rowObject) {
			console.log(rowObject.status);
			if(rowObject.status == 0){
				return '<span class="set-status open" data-delete="false" onclick="switchs(this,'+rowObject.id+')"><span class="ui-icon-circle"></span></span>';
			}else{
				return '<span class="set-status close" data-delete="false" onclick="switchs(this,'+rowObject.id+')"><span class="ui-icon-circle"></span></span>';
			}
			
		}

		function actions (cellvalue, options, rowObject) {
			return '<div class="operating"><span class="ui-icon ui-icon-pencil" onclick="lopen(\'edit.html?id='+rowObject.id+'\',\'编辑\',\'400px\',\'300px\')">修改</span> <span class="ui-icon ui-icon-trash" onclick="del('+rowObject.id+')">删除</span></div>';
		}

		function switchs(obj, id) {
			if($(obj).hasClass("open")){
				$(obj).removeClass("open");
				$(obj).addClass("close");
				status = 1;
			}else{
				$(obj).removeClass("close");
				$(obj).addClass("open");
				status = 0;
			}

			$.ajax({
				type: 'POST',
				url: "save.html",
				data: {id:id,status:status},
				dataType: "json",
				async: false,
				error: function (request) {
					layer.msg("发送请求失败！");
				},
				success: function (data) {
					if (data.status == 1) {
						layer.msg(data.msg);
					} else {
						layer.msg(data.msg);
					}

				}
			});
		}

		

		
	</script>

	{include file="public/footer"/}